SUBROUTINE SUGPD1S(NCID)
USE PARKIND1  ,ONLY : JPIM     ,JPRB,   JPRD
USE YOMHOOK   ,ONLY : LHOOK    ,DR_HOOK, JPHOOK
USE YOMLUN1S , ONLY : NULNAM   ,NULOUT
USE YOMGPD1S , ONLY : GPD, GPD_SDP2, GPD_SDP3       ,&
            &VFZ0F    ,VFALBF   ,VFITM    ,VFZ0H    ,&
            &VFALUVP  ,VFALUVD  ,VFALNIP  ,VFALNID  ,&
            &VFALUVI  ,VFALUVV  ,VFALUVG  , &
            &VFALNII  ,VFALNIV  ,VFALNIG  , &
            &VFCVL    ,VFCVH    ,VFCUR    ,VFTVL    ,VFTVH    ,&
            &VFCOVVT  ,VFR0VT   ,VFRSML   ,VFRSMH    ,&
            &VFLAIL   ,VFBVOCLAIL, VFLAIH ,VFBVOCLAIH, &
            &VFFWET   ,VFAVGPAR ,VFSST    ,VFISOP_EP   ,&
            &VFCI     ,VFCIL    , VFSOTY  ,VFSDOR  ,VFGEO    ,&
            &VDLSP    ,VDCP     ,VDSF     ,VDSSHF   ,VDSLHF   ,&
            &VDSSR    ,VDSTR    ,VDEWSS   ,VDNSSS   ,VDE      ,&
            &VDRO     ,VDALB    ,VDIEWSS  ,VDINSSS  ,VDISSHF  ,&
            &VDIE     ,VDCSF    ,VDLSSF   ,VDZ0F    ,VDZ0H    ,&
            &VDSSRD   ,VDSTRD   ,VDIEWSSTL,VDINSSSTL,VDISSHFTL,&
            &VDIETL   ,VDTSKTL  ,VDROS    ,VDMLT,&
            &VFLDEPTH ,VFCLAKE  ,VFCLAKEF, &!FLAKE 
            &VFCO2TYP,&
            &VFZO     ,VFHO     ,VFHO_INV ,VFDO     ,VFOCDEPTH,&   !KPP
            &VFADVT   ,VFADVS   ,VFTRI0   ,VFTRI1   ,VFSWDK_SAVE,& !KPP
            &VDANDAYVT,VDANFMVT ,&
            &VDRESPBSTR,VDRESPBSTR2,VDBIOMASS_LAST,VDBLOSSVT,VDBGAINVT,&
            &VFPGLOB, &
            &S2RVCOVH2D, S2RVCOVL2D, S2RVHSTRH2D, S2RVHSTRL2D, S2RVLAMSKH2D, &
            &S2RVLAMSKL2D, S2RVLAMSKSH2D, S2RVLAMSKSL2D, S2RVRSMINH2D, S2RVRSMINL2D, &
            &S2RVZ0HH2D, S2RVZ0HL2D, S2RVZ0MH2D, S2RVZ0ML2D, &
            &S2RVAHL2D, S2RVAMMAXH2D, S2RVAMMAXL2D, S2RVBHL2D, S2RVCEH2D, &
            &S2RVCEL2D, S2RVCFH2D, S2RVCFL2D, S2RVCNAH2D, S2RVCNAL2D, &
            &S2RVDMAXH2D, S2RVDMAXL2D, S2RVEPSOH2D, S2RVEPSOL2D, S2RVF2IH2D, &
            &S2RVF2IL2D, S2RVFZEROSTH2D, S2RVFZEROSTL2D, S2RVGAMMH2D, S2RVGAMML2D, &
            &S2RVGCH2D, S2RVGCL2D, S2RVGMESH2D, S2RVGMESL2D, S2RVLAIMINH2D, S2RVLAIMINL2D, &
            &S2RVQDAMMAXH2D, S2RVQDAMMAXL2D, S2RVQDGAMMH2D, S2RVQDGAMML2D, S2RVQDGMESH2D, &
            &S2RVQDGMESL2D, S2RVSEFOLDH2D, S2RVSEFOLDL2D, &
            &S2RVT1AMMAXH2D, S2RVT1AMMAXL2D, S2RVT1GMESH2D, S2RVT1GMESL2D, S2RVT2AMMAXH2D, &
            &S2RVT2AMMAXL2D, S2RVT2GMESH2D, S2RVT2GMESL2D, S2RVTOPTH2D, S2RVTOPTL2D, &
            &S2RXBOMEGAMH2D, S2RXBOMEGAML2D, S2RVRSMINB2D, S2RVANMAXH2D, S2RVANMAXL2D, &
            &S2RVBSLAI_NITROH2D, S2RVBSLAI_NITROL2D, &
            &S3RCGDRYM3D, S3RLAMBDAM3D, S3RMVGALPHA3D, S3RNFACM3D, S3RWCONSM3D, &
            &S3RWRESTM3D, S3RWSATM3D, S3RVROOTSAH3D, S3RVROOTSAL3D, S3RLAMBDADRYM3D, S3RLAMSAT1M3D, &
            &S3RRCSOILM3D, S3RWCAPM3D, S3RWPWPM3D, S3RMFACM3D, S3RDMAXM3D, S3RDMINM3D
  
USE PTRGPD1S , ONLY :  MVFZ0F   ,MVFALBF  ,MVFITM   ,&
            &MVFALUVP ,MVFALUVD ,MVFALNIP ,MVFALNID ,&
            &MVFALUVI ,MVFALUVV ,MVFALUVG ,&
            &MVFALNII ,MVFALNIV ,MVFALNIG ,&
            &MVFZ0H   ,MVFCVL   ,MVFCVH   ,MVFTVL   ,MVFTVH   ,&
            &MVFLAIL  ,MVFBVOCLAIL  ,MVFLAIH  ,MVFBVOCLAIH  ,MVFCUR   ,MVFFWET  ,MVFAVGPAR, MVFISOP_EP,&
            &MVFCOVVT ,MVFR0VT,MVFRSML  ,MVFRSMH,&
            &MVFSST   ,MVFCI    ,MVFCIL, MVFSOTY  ,MVFSDOR  ,MVFGEO   ,&
            &MVDLSP   ,MVDCP    ,MVDSF    ,MVDSSHF  ,MVDSLHF  ,&
            &MVDSSR   ,MVDSTR   ,MVDEWSS  ,MVDNSSS  ,MVDE     ,&
            &MVDRO    ,MVDALB   ,MVDIEWSS ,MVDINSSS ,MVDISSHF ,&
            &MVDIE    ,MVDCSF   ,MVDLSSF  ,MVDZ0F   ,MVDZ0H   ,&
            &MVDSSRD  ,MVDSTRD  ,MVDIEWSSTL,MVDINSSSTL,MVDISSHFTL,&
            &MVDIETL  ,MVDTSKTL ,MVDROS   ,MVDMLT,&
            &MVFLDEPTH,MVFCLAKE ,MVFCLAKEF, &!FLAKE
            &MVFCO2TYP,&
            &MVFZO    ,MVFHO    ,MVFHO_INV,MVFDO    ,MVFOCDEPTH,& !KPP
            &MVFADVT  ,MVFADVS  ,MVFTRI0  ,MVFTRI1  ,MVFSWDK_SAVE,& !KPP
            &MVDANDAYVT,MVDANFMVT,&
            &MVDRESPBSTR,MVDRESPBSTR2,MVDBIOMASS_LAST,MVDBLOSSVT,MVDBGAINVT,&
            &MVFPGLOB
            
USE YOMSURF_SSDP_MOD , ONLY : SSDP2D_ID, SSDP3D_ID, NSSDP2D, NSSDP3D 
USE YOMCC1S  , ONLY : GPCC,VCALB,VCLAIL,VCBVOCLAIL,VCBVOCLAIH,VCLAIH,VCFWET,VCAVGPAR
USE YOMLOG1S , ONLY : CFSURF
USE YOMDPHY  , ONLY : NVSF    ,NVPD     ,NGCC     ,NPOI,  NCSS   ,&
                     &NTILES  ,NVHILO  ,NVDIAG     ,&
                     &NCOM    ,NVELO    ,NSCLRO    ,&    !KPP
                     &NCLIMDAT
USE YOEPHY   , ONLY : LEOCML, LECLIM10D

#ifdef DOC
! (C) Copyright 1995- ECMWF.
!
! This software is licensed under the terms of the Apache Licence Version 2.0
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
! In applying this licence, ECMWF does not waive the privileges and immunities
! granted to it by virtue of its status as an intergovernmental organisation
! nor does it submit to any jurisdiction.

!**** *SUGPD1S*   - Routine to initialize soil and vegetation properties

!     Purpose.
!     --------
!           Initialize surface properties

!***  Interface.
!     ----------
!        *CALL* *SUGPD1S(NCID)

!     Explicit arguments :
!     --------------------
!        NCID : NETCDF INPUT FILE UNIT

!     Method.
!     -------
!        See documentation

!     Externals.
!     ----------
!        Called by SUINIF1S.

!     Reference.
!     ----------
!        ECMWF Research Department documentation 
!        of the one column surface model

!     Author.
!     -------
!        Jean-Francois Mahfouf and Pedro Viterbo  *ECMWF*

!     Modifications.
!     --------------
!        Original : 95-03-21
!        Bart vd HURK (KNMI) Multi-column input from netCDF
!        Gianpaolo Balsamo (ECMWF) add grib interface
!        Y. Takaya (ECMWF) add ocean mixed layer variables
!        E. Dutra (U.Lisbon) add Flake variables
!        G. Balsamo (ECMWF) add LAI
!        I. Ayan-Miguez (BSC) add Spatially distributed parameters group

#endif
IMPLICIT NONE

INTEGER NCID

INTEGER(KIND=JPIM) :: IVSF,IVCC,IVDIAG,MVCALB,MVCLAIL,MVCBVOCLAIL, MVCLAIH, MVCBVOCLAIH, MVCFWET,MVCAVGPAR
INTEGER(KIND=JPIM) :: IST,IEND,J,JMO,KULOUT

REAL(KIND=JPHOOK)    :: ZHOOK_HANDLE

#include "namgpd1s.h"
#include "rdclim.intfb.h"

IF (LHOOK) CALL DR_HOOK('SUGPD1S',0,ZHOOK_HANDLE)

!*        ALLOCATE TOTAL SIZE and pointer stuff.

KULOUT=NULOUT
   WRITE(UNIT=KULOUT,FMT=*) 'NVHILO=',NVHILO

ALLOCATE (GPD(NPOI,NVPD))
MVFZ0F=1
MVFALBF=MVFZ0F+1
MVFALUVP=MVFALBF+1
MVFALUVD=MVFALUVP+1
MVFALNIP=MVFALUVD+1
MVFALNID=MVFALNIP+1
MVFALUVI=MVFALNID+1
MVFALUVV=MVFALUVI+1
MVFALUVG=MVFALUVV+1
MVFALNII=MVFALUVG+1
MVFALNIV=MVFALNII+1
MVFALNIG=MVFALNIV+1
MVFITM=MVFALNIG+1
MVFGEO=MVFITM+1
MVFZ0H=MVFGEO+1
MVFCVL=MVFZ0H+1
MVFCVH=MVFCVL+1
MVFCUR=MVFCVH+1
MVFTVL=MVFCUR+1
MVFCO2TYP=MVFTVL+1
MVFTVH=MVFCO2TYP+1
MVFLAIL=MVFTVH+1
MVFBVOCLAIL=MVFLAIL+1
MVFLAIH=MVFBVOCLAIL+1
MVFBVOCLAIH=MVFLAIH+1
MVFFWET=MVFBVOCLAIH+1
MVFAVGPAR=MVFFWET+1
MVFISOP_EP=MVFAVGPAR+1
MVFRSML=MVFISOP_EP+1
MVFRSMH=MVFRSML+1

MVFSST=MVFRSMH+1
MVFCI=MVFSST+1
MVFCIL=MVFCI+1
MVFSOTY=MVFCIL+1
MVFSDOR=MVFSOTY+1
MVFR0VT=MVFSDOR+1


MVFCLAKE=MVFR0VT+NVHILO    ! FLAKE
MVFCLAKEF=MVFCLAKE+1
MVFLDEPTH=MVFCLAKEF+1  ! FLAKE (same as above)
MVFPGLOB=MVFLDEPTH+1

MVFZO = MVFPGLOB+1              !KPP
MVFHO = MVFZO+NCOM+1             !KPP
MVFHO_INV = MVFHO+NCOM+1         !KPP
MVFDO = MVFHO_INV+NCOM+1         !KPP
MVFADVT = MVFDO+NCOM+1           !KPP
MVFADVS = MVFADVT+NCOM           !KPP
MVFTRI0 = MVFADVS+NCOM           !KPP
MVFTRI1 = MVFTRI0 + NCOM+1       !KPP 
MVFSWDK_SAVE = MVFTRI1 + NCOM+1  !KPP
MVFOCDEPTH = MVFSWDK_SAVE + NCOM+1 !KPP
IVSF=MVFOCDEPTH                    ! KPP

MVDLSP=MVFOCDEPTH+1   
MVDCP=MVDLSP+1
MVDSF=MVDCP+1
MVDSSHF=MVDSF+1
MVDSLHF=MVDSSHF+1
MVDSSR=MVDSLHF+1
MVDSTR=MVDSSR+1
MVDEWSS=MVDSTR+1
MVDNSSS=MVDEWSS+1
MVDE=MVDNSSS+1
MVDRO=MVDE+1
MVDROS=MVDRO+1
MVDMLT=MVDROS+1
MVDALB=MVDMLT+1
MVDIEWSS=MVDALB+1
MVDINSSS=MVDIEWSS+1
MVDISSHF=MVDINSSS+1
MVDIE=MVDISSHF+1
MVDCSF=MVDIE+1
MVDLSSF=MVDCSF+1
MVDZ0F=MVDLSSF+1
MVDZ0H=MVDZ0F+1
MVDSSRD=MVDZ0H+1
MVDSTRD=MVDSSRD+1
MVDIEWSSTL=MVDSTRD+1
MVDINSSSTL=MVDIEWSSTL+NTILES
MVDISSHFTL=MVDINSSSTL+NTILES
MVDIETL=MVDISSHFTL+NTILES
MVDTSKTL=MVDIETL+NTILES

MVDANDAYVT=MVDTSKTL+NTILES
MVDANFMVT=MVDANDAYVT+NVHILO
MVDRESPBSTR=MVDANFMVT+NVHILO
MVDRESPBSTR2=MVDRESPBSTR+NVHILO
MVDBIOMASS_LAST=MVDRESPBSTR2+NVHILO
MVDBLOSSVT=MVDBIOMASS_LAST+NVHILO
MVDBGAINVT=MVDBLOSSVT+NVHILO
IVDIAG=MVDBGAINVT+NVHILO-(IVSF)


   WRITE(UNIT=KULOUT,FMT=*) 'pointer dimension finish'

VFZ0F => GPD(:,MVFZ0F)
VFALBF => GPD(:,MVFALBF)
VFALUVP => GPD(:,MVFALUVP)
VFALUVD => GPD(:,MVFALUVD)
VFALNIP => GPD(:,MVFALNIP)
VFALNID => GPD(:,MVFALNID)
VFALUVI => GPD(:,MVFALUVI)
VFALUVV => GPD(:,MVFALUVV)
VFALUVG => GPD(:,MVFALUVG)
VFALNII => GPD(:,MVFALNII)
VFALNIV => GPD(:,MVFALNIV)
VFALNIG => GPD(:,MVFALNIG)
VFITM => GPD(:,MVFITM)
VFGEO => GPD(:,MVFGEO)
VFZ0H => GPD(:,MVFZ0H)
VFCVL => GPD(:,MVFCVL)
VFCVH => GPD(:,MVFCVH)
VFCUR => GPD(:,MVFCUR)
VFTVL => GPD(:,MVFTVL)
VFCO2TYP => GPD(:,MVFCO2TYP)
VFTVH => GPD(:,MVFTVH)
VFLAIL => GPD(:,MVFLAIL)
VFBVOCLAIL => GPD(:,MVFBVOCLAIL)
VFLAIH => GPD(:,MVFLAIH)
VFBVOCLAIH => GPD(:,MVFBVOCLAIH)
VFFWET => GPD(:,MVFFWET)
VFAVGPAR => GPD(:,MVFAVGPAR)
VFISOP_EP => GPD(:,MVFISOP_EP)

VFRSML=> GPD(:,MVFRSML)
VFRSMH=> GPD(:,MVFRSMH)


VFSST => GPD(:,MVFSST)
VFCI => GPD(:,MVFCI)
VFCIL => GPD(:,MVFCIL)
VFSOTY => GPD(:,MVFSOTY)
VFSDOR => GPD(:,MVFSDOR)

VFR0VT => GPD(:,MVFR0VT:MVFR0VT+NVHILO-1)


VDLSP => GPD(:,MVDLSP)
VDCP => GPD(:,MVDCP)
VDSF => GPD(:,MVDSF)
VDSSHF => GPD(:,MVDSSHF)
VDSLHF => GPD(:,MVDSLHF)
VDSSR => GPD(:,MVDSSR)
VDSTR => GPD(:,MVDSTR)
VDEWSS => GPD(:,MVDEWSS)
VDNSSS => GPD(:,MVDNSSS)
VDE => GPD(:,MVDE)
VDRO => GPD(:,MVDRO)
VDROS => GPD(:,MVDROS)
VDMLT => GPD(:,MVDMLT)
VDALB => GPD(:,MVDALB)
VDIEWSS => GPD(:,MVDIEWSS)
VDINSSS => GPD(:,MVDINSSS)
VDISSHF => GPD(:,MVDISSHF)
VDIE => GPD(:,MVDIE)
VDCSF => GPD(:,MVDCSF)
VDLSSF => GPD(:,MVDLSSF)
VDZ0F => GPD(:,MVDZ0F)
VDZ0H => GPD(:,MVDZ0H)
VDSSRD => GPD(:,MVDSSRD)
VDSTRD => GPD(:,MVDSTRD)
VDIEWSSTL => GPD(:,MVDIEWSSTL:MVDIEWSSTL+NTILES-1)
VDINSSSTL => GPD(:,MVDINSSSTL:MVDINSSSTL+NTILES-1)
VDISSHFTL => GPD(:,MVDISSHFTL:MVDISSHFTL+NTILES-1)
VDIETL => GPD(:,MVDIETL:MVDIETL+NTILES-1)
VDTSKTL => GPD(:,MVDTSKTL:MVDTSKTL+NTILES-1)

VFLDEPTH => GPD(:,MVFLDEPTH) !FLAKE  
VFCLAKE => GPD(:,MVFCLAKE)   !FLAKE 
VFCLAKEF => GPD(:,MVFCLAKEF)   !FLAKE + FLood

VFPGLOB => GPD(:,MVFPGLOB)  ! Global gaussian reduced index 

VFZO => GPD(:,MVFZO:MVFZO+(NCOM+1)-1)   !KPP
VFHO => GPD(:,MVFHO:MVFHO+(NCOM+1)-1)   !KPP
VFHO_INV => GPD(:,MVFHO_INV:MVFHO_INV+(NCOM+1)-1) !KPP
VFDO => GPD(:,MVFDO:MVFDO+(NCOM+1)-1)   !KPP
VFADVT => GPD(:,MVFADVT:MVFADVT+NCOM-1) !KPP
VFADVS => GPD(:,MVFADVS:MVFADVS+NCOM-1) !KPP
VFTRI0 => GPD(:,MVFTRI0:MVFTRI0+(NCOM+1)-1) !KPP
VFTRI1 => GPD(:,MVFTRI1:MVFTRI1+(NCOM+1)-1) !KPP
VFSWDK_SAVE => GPD(:,MVFSWDK_SAVE:MVFSWDK_SAVE+(NCOM+1)-1) !KPP
VFOCDEPTH => GPD(:,MVFOCDEPTH) !KPP

VDANDAYVT => GPD(:,MVDANDAYVT:MVDANDAYVT+NVHILO-1)
VDANFMVT => GPD(:,MVDANFMVT:MVDANFMVT+NVHILO-1)
VDRESPBSTR => GPD(:,MVDRESPBSTR:MVDRESPBSTR+NVHILO-1)
VDRESPBSTR2 => GPD(:,MVDRESPBSTR2:MVDRESPBSTR2+NVHILO-1)
VDBIOMASS_LAST => GPD(:,MVDBIOMASS_LAST:MVDBIOMASS_LAST+NVHILO-1)
VDBLOSSVT => GPD(:,MVDBLOSSVT:MVDBLOSSVT+NVHILO-1)
VDBGAINVT => GPD(:,MVDBGAINVT:MVDBGAINVT+NVHILO-1)

! 2D spatially distributed parameters
ALLOCATE (GPD_SDP2(NPOI,NSSDP2D)) 
S2RVCOVH2D     => GPD_SDP2(:,SSDP2D_ID%NRVCOVH2D)
S2RVCOVL2D     => GPD_SDP2(:,SSDP2D_ID%NRVCOVL2D)
S2RVLAMSKH2D   => GPD_SDP2(:,SSDP2D_ID%NRVLAMSKH2D)
S2RVLAMSKL2D   => GPD_SDP2(:,SSDP2D_ID%NRVLAMSKL2D)
S2RVLAMSKSH2D  => GPD_SDP2(:,SSDP2D_ID%NRVLAMSKSH2D)
S2RVLAMSKSL2D  => GPD_SDP2(:,SSDP2D_ID%NRVLAMSKSL2D)
S2RVRSMINH2D   => GPD_SDP2(:,SSDP2D_ID%NRVRSMINH2D)
S2RVRSMINL2D   => GPD_SDP2(:,SSDP2D_ID%NRVRSMINL2D)
S2RVZ0HH2D     => GPD_SDP2(:,SSDP2D_ID%NRVZ0HH2D)
S2RVZ0HL2D     => GPD_SDP2(:,SSDP2D_ID%NRVZ0HL2D)
S2RVZ0MH2D     => GPD_SDP2(:,SSDP2D_ID%NRVZ0MH2D)
S2RVZ0ML2D     => GPD_SDP2(:,SSDP2D_ID%NRVZ0ML2D)
S2RVAHL2D      => GPD_SDP2(:,SSDP2D_ID%NRVAHL2D)
S2RVAMMAXH2D   => GPD_SDP2(:,SSDP2D_ID%NRVAMMAXH2D)
S2RVAMMAXL2D   => GPD_SDP2(:,SSDP2D_ID%NRVAMMAXL2D)
S2RVBHL2D      => GPD_SDP2(:,SSDP2D_ID%NRVBHL2D)
S2RVCEH2D      => GPD_SDP2(:,SSDP2D_ID%NRVCEH2D)
S2RVCEL2D      => GPD_SDP2(:,SSDP2D_ID%NRVCEL2D)
S2RVCFH2D      => GPD_SDP2(:,SSDP2D_ID%NRVCFH2D)
S2RVCFL2D      => GPD_SDP2(:,SSDP2D_ID%NRVCFL2D)
S2RVCNAH2D     => GPD_SDP2(:,SSDP2D_ID%NRVCNAH2D) 
S2RVCNAL2D     => GPD_SDP2(:,SSDP2D_ID%NRVCNAL2D)
S2RVDMAXH2D    => GPD_SDP2(:,SSDP2D_ID%NRVDMAXH2D)
S2RVDMAXL2D    => GPD_SDP2(:,SSDP2D_ID%NRVDMAXL2D)
S2RVEPSOH2D    => GPD_SDP2(:,SSDP2D_ID%NRVEPSOH2D)
S2RVEPSOL2D    => GPD_SDP2(:,SSDP2D_ID%NRVEPSOL2D)
S2RVF2IH2D     => GPD_SDP2(:,SSDP2D_ID%NRVF2IH2D)
S2RVF2IL2D     => GPD_SDP2(:,SSDP2D_ID%NRVF2IL2D)
S2RVFZEROSTH2D => GPD_SDP2(:,SSDP2D_ID%NRVFZEROSTH2D)
S2RVFZEROSTL2D => GPD_SDP2(:,SSDP2D_ID%NRVFZEROSTL2D)
S2RVGAMMH2D    => GPD_SDP2(:,SSDP2D_ID%NRVGAMMH2D)
S2RVGAMML2D    => GPD_SDP2(:,SSDP2D_ID%NRVGAMML2D)
S2RVGCH2D      => GPD_SDP2(:,SSDP2D_ID%NRVGCH2D)
S2RVGCL2D      => GPD_SDP2(:,SSDP2D_ID%NRVGCL2D)
S2RVGMESH2D    => GPD_SDP2(:,SSDP2D_ID%NRVGMESH2D)
S2RVGMESL2D    => GPD_SDP2(:,SSDP2D_ID%NRVGMESL2D)
S2RVLAIMINH2D  => GPD_SDP2(:,SSDP2D_ID%NRVLAIMINH2D)
S2RVLAIMINL2D  => GPD_SDP2(:,SSDP2D_ID%NRVLAIMINL2D)
S2RVQDAMMAXH2D => GPD_SDP2(:,SSDP2D_ID%NRVQDAMMAXH2D)
S2RVQDAMMAXL2D => GPD_SDP2(:,SSDP2D_ID%NRVQDAMMAXL2D)
S2RVQDGAMMH2D  => GPD_SDP2(:,SSDP2D_ID%NRVQDGAMMH2D)
S2RVQDGAMML2D  => GPD_SDP2(:,SSDP2D_ID%NRVQDGAMML2D)
S2RVQDGMESH2D  => GPD_SDP2(:,SSDP2D_ID%NRVQDGMESH2D)
S2RVQDGMESL2D  => GPD_SDP2(:,SSDP2D_ID%NRVQDGMESL2D)
S2RVSEFOLDH2D  => GPD_SDP2(:,SSDP2D_ID%NRVSEFOLDH2D)
S2RVSEFOLDL2D  => GPD_SDP2(:,SSDP2D_ID%NRVSEFOLDL2D)
S2RVT1AMMAXH2D => GPD_SDP2(:,SSDP2D_ID%NRVT1AMMAXH2D)
S2RVT1AMMAXL2D => GPD_SDP2(:,SSDP2D_ID%NRVT1AMMAXL2D)
S2RVT1GMESH2D  => GPD_SDP2(:,SSDP2D_ID%NRVT1GMESH2D)
S2RVT1GMESL2D  => GPD_SDP2(:,SSDP2D_ID%NRVT1GMESL2D)
S2RVT2AMMAXH2D => GPD_SDP2(:,SSDP2D_ID%NRVT2AMMAXH2D)
S2RVT2AMMAXL2D => GPD_SDP2(:,SSDP2D_ID%NRVT2AMMAXL2D)
S2RVT2GMESH2D  => GPD_SDP2(:,SSDP2D_ID%NRVT2GMESH2D)
S2RVT2GMESL2D  => GPD_SDP2(:,SSDP2D_ID%NRVT2GMESL2D)
S2RVTOPTH2D    => GPD_SDP2(:,SSDP2D_ID%NRVTOPTH2D)
S2RVTOPTL2D    => GPD_SDP2(:,SSDP2D_ID%NRVTOPTL2D)
S2RXBOMEGAMH2D => GPD_SDP2(:,SSDP2D_ID%NRXBOMEGAMH2D)
S2RXBOMEGAML2D => GPD_SDP2(:,SSDP2D_ID%NRXBOMEGAML2D)
S2RVRSMINB2D   => GPD_SDP2(:,SSDP2D_ID%NRVRSMINB2D)
S2RVANMAXH2D   => GPD_SDP2(:,SSDP2D_ID%NRVANMAXH2D)
S2RVANMAXL2D   => GPD_SDP2(:,SSDP2D_ID%NRVANMAXL2D)
S2RVBSLAI_NITROH2D => GPD_SDP2(:,SSDP2D_ID%NRVBSLAI_NITROH2D)
S2RVBSLAI_NITROL2D  => GPD_SDP2(:,SSDP2D_ID%NRVBSLAI_NITROL2D)


ALLOCATE (GPD_SDP3(NPOI,NCSS,NSSDP3D)) 
S3RCGDRYM3D    => GPD_SDP3(:,:,SSDP3D_ID%NRCGDRYM3D)
S3RLAMBDAM3D   => GPD_SDP3(:,:,SSDP3D_ID%NRLAMBDAM3D)
S3RMVGALPHA3D  => GPD_SDP3(:,:,SSDP3D_ID%NRMVGALPHA3D)
S3RNFACM3D     => GPD_SDP3(:,:,SSDP3D_ID%NRNFACM3D)
S3RWCONSM3D    => GPD_SDP3(:,:,SSDP3D_ID%NRWCONSM3D)
S3RWRESTM3D    => GPD_SDP3(:,:,SSDP3D_ID%NRWRESTM3D)
S3RWSATM3D     => GPD_SDP3(:,:,SSDP3D_ID%NRWSATM3D)
S3RVROOTSAH3D  => GPD_SDP3(:,:,SSDP3D_ID%NRVROOTSAH3D)
S3RVROOTSAL3D  => GPD_SDP3(:,:,SSDP3D_ID%NRVROOTSAL3D)
S3RLAMBDADRYM3D=> GPD_SDP3(:,:,SSDP3D_ID%NRLAMBDADRYM3D)
S3RLAMSAT1M3D  => GPD_SDP3(:,:,SSDP3D_ID%NRLAMSAT1M3D)
S3RRCSOILM3D   => GPD_SDP3(:,:,SSDP3D_ID%NRRCSOILM3D)
S3RWCAPM3D     => GPD_SDP3(:,:,SSDP3D_ID%NRWCAPM3D)
S3RWPWPM3D     => GPD_SDP3(:,:,SSDP3D_ID%NRWPWPM3D)
S3RMFACM3D     => GPD_SDP3(:,:,SSDP3D_ID%NRMFACM3D)
S3RDMAXM3D     => GPD_SDP3(:,:,SSDP3D_ID%NRDMAXM3D)
S3RDMINM3D     => GPD_SDP3(:,:,SSDP3D_ID%NRDMINM3D)
 
WRITE(KULOUT,*) 'pointer allocation finish'

!*        ALLOCATE TOTAL SIZE and pointer stuff for seasonal array.

ALLOCATE (GPCC(NPOI,NCLIMDAT,NGCC))


MVCALB=1
MVCLAIL=MVCALB+1
MVCBVOCLAIL=MVCLAIL+1
MVCLAIH=MVCBVOCLAIL+1
MVCBVOCLAIH=MVCLAIH+1
MVCFWET=MVCBVOCLAIH+1
MVCAVGPAR=MVCFWET+1
IVCC=MVCAVGPAR

VCALB => GPCC(:,:,MVCALB)
VCLAIL => GPCC(:,:,MVCLAIL)
VCBVOCLAIL => GPCC(:,:,MVCBVOCLAIL)
VCLAIH => GPCC(:,:,MVCLAIH)
VCBVOCLAIH => GPCC(:,:,MVCBVOCLAIH)
VCFWET => GPCC(:,:,MVCFWET)
VCAVGPAR => GPCC(:,:,MVCAVGPAR)

  WRITE(KULOUT,*) 'climate pointer allocation finish'
! final checking

IF (IVSF /= NVSF) THEN
  WRITE(KULOUT,*) ' SUGPD1S: ARRAY GPD'
  WRITE(KULOUT,*) ' INCONSISTENCY IN THE SPACE FOR THE CLIMATE'
  WRITE(KULOUT,*) ' PART OF GENERAL ARRAY'
  WRITE(KULOUT,*) ' NVSF=',NVSF,'IVSF=',IVSF
  WRITE(KULOUT,*) ' CHANGE THE SIZE OF NVSF'
  CALL ABORT
ENDIF

IF (IVDIAG /= NVDIAG) THEN
  WRITE(KULOUT,*) ' SUGPD1S: ARRAY GPD'
  WRITE(KULOUT,*) ' INCONSISTENCY IN THE SPACE FOR THE DIAGNOSTICS'
  WRITE(KULOUT,*) ' PART OF GENERAL ARRAY'
  WRITE(KULOUT,*) ' CHANGE THE SIZE OF NVDIAG'
  WRITE(KULOUT,*) ' NVDIAG=',NVDIAG,'IVDIAG=',IVDIAG
  WRITE(KULOUT,*) ' IVDIAG,NVDIAG=',IVDIAG,NVDIAG
  CALL ABORT
ENDIF

IF (IVCC /= NGCC) THEN
  WRITE(KULOUT,*) ' SUGPD1S: ARRAY GPCC'
  WRITE(KULOUT,*) ' INCONSISTENCY IN THE SPACE FOR THE SEASONALLY'
  WRITE(KULOUT,*) ' VARYING ARRAY'
  WRITE(KULOUT,*) ' NGCC=',NGCC,'IVCC=',IVCC
  WRITE(KULOUT,*) ' CHANGE THE SIZE OF NGCC'
  CALL ABORT
ENDIF


!*         1.  Initialisation to absurd values

IST=1
IEND=NPOI
GPD(IST:IEND,1:NVSF)=-999._JPRB

! Initialise the rest as well
GPD(IST:IEND,NVSF+1:NVPD)=0.0_JPRB

GPCC(IST:IEND,NCLIMDAT,1:NGCC)=-999._JPRB


IF ( CFSURF == 'netcdf' ) THEN

!*         1.  Read surface characteristics from NetCDF file(s)
  WRITE(KULOUT,*) 'Entring RDCLIM'
  CALL RDCLIM(NCID)
  WRITE(KULOUT,*) 'RDCLIM is over'

ELSE

!*       2.    Modifies default values.

  VGEO=0._JPRB ! Default value | VGEO is not in namelist namgpd1s 
  

!        2.1   Read namelist

  REWIND(NULNAM)
  READ(NULNAM,NAMGPD1S)

  VCALB(1,:)=VALBF(:)
  VCLAIL(1,:)=VLAIL(:)
  VCLAIH(1,:)=VLAIH(:)
  VFRSML=VRSML
  VFRSMH=VRSMH

  VGEO=0._JPRB
  VFZ0F=VZ0F
  VFITM=VITM
  VFGEO=VGEO
  VFZ0H=VZ0H
  VFCVL=VCVL
  VFCVH=VCVH
  VFCUR=VCUR
  VFTVL=VTVL
  VFCO2TYP=VCO2TYP
  VFTVH=VTVH
  VFSOTY=VSOTY
  VFSDOR=VSDOR
  VFSST=VSST
  VFCI=VCI
  VFCIL=VCIL
  VFLDEPTH=VLDEPTH  !FLAKE 
  VFCLAKE=VCLAKE    !FLAKE 

  VFR0VT(:,1)=VR0L   
  VFR0VT(:,2)=VR0H


! Mock value of albedo for checking
  VFALBF=SUM(VCALB,DIM=2)/NCLIMDAT
  VFALUVP=VFALBF
  VFALUVD=VFALBF
  VFALNIP=VFALBF
  VFALNID=VFALBF
  VFALUVI=VFALBF
  VFALUVV=0.0_JPRB
  VFALUVG=0.0_JPRB
  VFALNII=VFALBF
  VFALNIV=0.0_JPRB
  VFALNIG=0.0_JPRB
  VFLAIL=SUM(VCLAIL,DIM=2)/NCLIMDAT
  VFBVOCLAIL=SUM(VCBVOCLAIL,DIM=2)/NCLIMDAT
  VFLAIH=SUM(VCLAIH,DIM=2)/NCLIMDAT
  VFBVOCLAIH=SUM(VCBVOCLAIH,DIM=2)/NCLIMDAT

  IF (.NOT. LEOCML) THEN
    VFZO = 0.0_JPRB
    VFHO = 0.0_JPRB
    VFHO_INV = 0.0_JPRB
    VFDO = 0.0_JPRB
    VFADVT = 0.0_JPRB
    VFADVS = 0.0_JPRB
    VFTRI0 = 0.0_JPRB
    VFTRI1 = 0.0_JPRB
    VFSWDK_SAVE = 0.0_JPRB
    VFOCDEPTH = 0.0_JPRB
    PRINT *,"OCEAN DIAGNOSTIC INIT to 0"
  ENDIF

!*       3.    Print final values.

  DO J=1,NVSF
    IF (GPD(1,J) == -999._JPRB) THEN
      WRITE(KULOUT,*) 'PB WITH SURFACE PROPERTIES ', J,"VARIABLE"
      CALL ABORT
    ENDIF
  ENDDO
  DO J=1,NGCC
    do jmo=1,NCLIMDAT
      IF (GPCC(1,jmo,J) == -999._JPRB) THEN
        WRITE(KULOUT,*) 'PB WITH SURFACE SEASONAL PROPERTIES '
        CALL ABORT
      ENDIF
    enddo
  ENDDO
  WRITE(UNIT=KULOUT,FMT='('' MODULE YOMGPD1S '')')
  WRITE(UNIT=KULOUT,FMT=*) ' VFZ0F   =  ',VFZ0F
  WRITE(UNIT=KULOUT,FMT=*) ' VFITM   =  ',VFITM
  WRITE(UNIT=KULOUT,FMT=*) ' VFGEO   =  ',VFGEO
  WRITE(UNIT=KULOUT,FMT=*) ' VFZ0H  =  ',VFZ0H
  WRITE(UNIT=KULOUT,FMT=*) ' VFCVL  =  ',VFCVL
  WRITE(UNIT=KULOUT,FMT=*) ' VFCVH  =  ',VFCVH
  WRITE(UNIT=KULOUT,FMT=*) ' VFCUR  =  ',VFCUR
  WRITE(UNIT=KULOUT,FMT=*) ' VFTVL  =  ',VFTVL
  WRITE(UNIT=KULOUT,FMT=*) ' VFCO2TYP  =  ',VFCO2TYP
  WRITE(UNIT=KULOUT,FMT=*) ' VFTVH  =  ',VFTVH
  WRITE(UNIT=KULOUT,FMT=*) ' VFSST  =  ',VFSST
  WRITE(UNIT=KULOUT,FMT=*) ' VFCI   =  ',VFCI
  WRITE(UNIT=KULOUT,FMT=*) ' VFCIL  =  ',VFCIL
  WRITE(UNIT=KULOUT,FMT=*) ' VFSOTY =  ',VFSOTY
  WRITE(UNIT=KULOUT,FMT=*) ' VFSDOR =  ',VFSDOR
  WRITE(UNIT=KULOUT,FMT=*) 'VFLDEPTH=  ',VFLDEPTH    !FLAKE 
  WRITE(UNIT=KULOUT,FMT=*) 'VFCLAKE=  ',VFCLAKE      !FLAKE 
  WRITE(UNIT=KULOUT,FMT=*) ' VFRSML =  ',VFRSML
  WRITE(UNIT=KULOUT,FMT=*) ' VFRSMH=   ',VFRSMH
  WRITE(UNIT=KULOUT,FMT=*) ' VFR0H=   ',VR0H
  WRITE(UNIT=KULOUT,FMT=*) ' VFR0L=   ',VR0L

  WRITE(UNIT=KULOUT,FMT='('' MODULE YOMGCC1S '')')
  WRITE(UNIT=KULOUT,FMT=*) ' VCALB  =  ',VCALB
  WRITE(UNIT=KULOUT,FMT=*) ' VCLAIL =  ',VCLAIL
  WRITE(UNIT=KULOUT,FMT=*) ' VCLAIH =  ',VCLAIH

ENDIF

IF (LHOOK) CALL DR_HOOK('SUGPD1S',1,ZHOOK_HANDLE)

RETURN
END SUBROUTINE SUGPD1S
